package com.brayan.webapp.model;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;

@Entity
public class UploadedImage implements Serializable {
	private static final long serialVersionUID = -8192553629588066292L;
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column
	private Long id;
	
	/** The optional publication id, which this image refers.*/
	@ManyToMany( mappedBy = "uploadedImages")
	private List<Pub> pubs;
	
	@Column
	private String title;
	
	@Column
	private Integer length;
	/** Name of the picture e.g. john_wayne.png*/
	@Column
	private String name;
	@Column
	private String fileType;
	@Column
	private String mimeType;
	@Lob
	@Column
	@Basic(fetch = FetchType.LAZY)
	private byte[] data;


	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
	public List<Pub> getPubs() {
		return pubs;
	}

	public void setPubs(List<Pub> pubs) {
		this.pubs = pubs;
	}

	public Integer getLength() {
		return length;
	}

	public void setLength(Integer length) {
		this.length = length;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getFileType() {
		return fileType;
	}

	public void setFileType(String fileType) {
		this.fileType = fileType;
	}

	public String getMimeType() {
		return mimeType;
	}

	public void setMimeType(String mimeType) {
		this.mimeType = mimeType;
	}

	public byte[] getData() {
		return data;
	}

	public void setData(byte[] data) {
		this.data = data;
	}
}
